<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<title>Carousel - Module Tabs</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">

	<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/utilities/utilities.js&2.6.0/build/container/container_core-min.js"></script> 
	<script type="text/javascript" src="scripts/carousel.js"></script>

	<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/combo?2.6.0/build/reset-fonts-grids/reset-fonts-grids.css&2.6.0/build/base/base-min.css">
	<link href="css/carousel.css" rel="stylesheet" type="text/css">
	<link href="css/yui.css" rel="stylesheet" type="text/css">
<!-- 
	Inlined styles for my overrides to the carousel for this demo.
	Normally I would put this in a separate CSS file.
-->
<style type="text/css">
.carousel-component { 
	padding:0px 0px 0px 0px;
	margin-bottom:10px;
	-moz-border-radius:0px;
	background-color: white;
	clear:both;
}

.carousel-component .carousel-clip-region { 
	padding:0px;
	margin:0px;

}
.carousel-component ul.carousel-list{
	text-align:left;
	background-color:white;
}
.carousel-component .carousel-list li { 
	text-align:left;
	margin:0px;
	width:450px;
	border: 1px solid gray;	
}
	
#tabset {
	margin-left:5px;
	margin-bottom:2px;
}
									
</style>

<script type="text/javascript">

var tabPages = [
			"images/tab-one-contents.png",
			"images/tab-two-contents.png",
			"images/tab-three-contents.png",
			"images/tab-four-contents.png"
			];
			
/**
 * Custom inital load handler. Called when the carousel loads the initial
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadInitHandler
 **/
var loadInitialItems = function(type, args) {

	var start = args[0];
	var last = args[1]; 

	load(this, start, last);	
};

/**
 * Custom load next handler. Called when the carousel loads the next
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadNextHandler
 **/
var loadNextItems = function(type, args) {	

	var start = args[0];
	var last = args[1]; 
	var alreadyCached = args[2];
	
	if(!alreadyCached) {
		load(this, start, last);
	}
};

/**
 * Custom load previous handler. Called when the carousel loads the previous
 * set of data items. Specified to the carousel as the configuration
 * parameter: loadPrevHandler
 **/
var loadPrevItems = function(type, args) {
	var start = args[0];
	var last = args[1]; 
	var alreadyCached = args[2];
	
	if(!alreadyCached) {
		load(this, start, last);
	}
};

var load = function(carousel, start, last) {
	for(var i=start;i<=last;i++) {
		carousel.addItem(i, fmtItem(tabPages[i-1]));
	}
};

var changePage = function(e, args) {
	var carousel = args[0];
	var pageNum = args[1];
	
	carousel.scrollTo(pageNum);
};

/**
 * You must create the carousel after the page is loaded since it is
 * dependent on an HTML element (in this case 'dhtml-carousel'.) See the
 * HTML code below.
 **/
var carousel; // for ease of debugging; globals generally not a good idea

var pageLoad = function() 
{
	carousel = new YAHOO.extension.Carousel("dhtml-carousel", 
		{
			numVisible:        1,
			animationSpeed:    0.35,
			scrollInc:         1,
			size:              4,
			navMargin:         0,
			loadInitHandler:   loadInitialItems,
			loadNextHandler:   loadNextItems,
			loadPrevHandler:   loadPrevItems
		}
	);
	YAHOO.util.Event.addListener(this.carouselNext, "click", this._scrollNext, this);

	YAHOO.util.Event.addListener("tab1", "click", changePage, [carousel, 1]);
	YAHOO.util.Event.addListener("tab2", "click", changePage, [carousel, 2]);
	YAHOO.util.Event.addListener("tab3", "click", changePage, [carousel, 3]);
	YAHOO.util.Event.addListener("tab4", "click", changePage, [carousel, 4]);
};

/**
 * Since carousel.addItem uses an HTML string to create the interface
 * for each carousel item, this method formats the HTML for an LI.
 **/
var fmtItem = function(tabPage) {

  	var innerHTML = 
  		'<img src="' + 
  		tabPage + 
  		'"/>';
  
	return innerHTML;
	
};


YAHOO.util.Event.addListener(window, 'load', pageLoad);


</script>
</head>

<body>

<div id="doc" class="yui-t7">
   <div id="hd">
		<h1>Module Tabs - Carousel (1 at a time, zero animation, external controls)</h1>
   </div>
<div id="bd">
<p>Example of showing one page of
      content at at time in tabs. Each tab link scrolls to the page selected. 
      Since all animation is turned off (animationSpeed = 0) then it just moves the desired 
      content into view.</p>
      <p>Note that in this demo, the content is an image. In reality you would create
      the desired HTML content for each page during the various carousel load handlers.</p>

<!-- Carousel Structure -->

<div id="tabset">Page:&nbsp;<a id="tab1" href="#">1</a>&nbsp;&nbsp;<a id="tab2" href="#">2</a>&nbsp;&nbsp;<a id="tab3" href="#">3</a>&nbsp;&nbsp;<a id="tab4" href="#">4</a></div>



<div id="dhtml-carousel" class="carousel-component">
	<div class="carousel-clip-region">
		<ul class="carousel-list">
			<!-- Filled in via the loadInitHandler, loadNextHandler, and loadPrevHandler
			<li id="item-1">
			<a href="#">
				<img src="http://static.flickr.com/74/162582364_7fc3e2d60d_s.jpg"/>
			</a>Number One</li>
			-->
		</ul>
	</div>
</div>


<div style="padding-top:20px;clear:both">View the <a href="source.php?url=carousel_tabs.html">source</a>&nbsp;or&nbsp;<a href="index.html">documentation</a></div>

</div>
</div> 

</body>
</html>